﻿var PrizeTypeJson;
var pageSize = 15;
$(document).ready(function () {

    //按照比赛名称进行 查询
    $.ajax({
        type: "post",
        data: { action: "GetList" },
        dataType: "json",
        url: "../../Ajax/PrizeTypeAjax.ashx",
        beforeSend: function () {
        },
        success: function (data) {
            if (data != null) {
                PrizeTypeJson = data.json;
                $("#seleByType").append(InitSelectByType());
                PageClickFunc(1);
            }
        },
        complete: function () {
        },
        error: function () {
        }
    });

    $("#btnSele").click(function () {
        InitTaskName(1)
    })
    $("#txtsysAccount").focus(function () {
        if ($(this).val() == "输入系统账号查询") {
            $(this).val("");
        }
    });
    $("#txtsysAccount").blur(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("default"));
        }

    });
    $("#seleByType").change(function () {
        PageClickFunc(1);
    })
})

//查询下拉框选择方法
function InitSelectByType() {
    var sel = "";
    $.each(PrizeTypeJson, function (k, v) {
        if (k == 0) {
            sel += "<option value='" + v.ID + "' selected='selected'>" + v.Name + "</option>";
        }
        else
            sel += "<option value='" + v.ID + "'>" + v.Name + "</option>";
    })
    return sel;
}
PageClickFunc = function (pageclickednumber) {
    InitTaskName(pageclickednumber);
}
function InitTaskName(pageclickednumber) {
    $.ajax({
        type: "post",
        data: { action: "Select", typeID: $("#seleByType").val(), sysAccount: $("#txtsysAccount").val() == "输入系统账号查询" ? "" : $("#txtsysAccount").val(), pageIndex: pageclickednumber, pageSize: pageSize },
        dataType: "json",
        url: "../../Ajax/PayOrderManage.ashx",
        beforeSend: function () {
        },
        success: function (data) {
            if (data != null) {
                var json = data.json;
                var tbody = "";
                var pageCount = data.flag;
                $.each(json, function (k, v) {
                    tbody += "<tr>"
                    tbody += "<td><lable name='lblOrderID' id='" + v.OrderID + "'>";
                    tbody += v.Name;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblOrderID'>";
                    tbody += v.OrderAccount;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblIMSI'>";
                    tbody += v.IMSI;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblScore'>";
                    tbody += v.Price;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblState'>";
                    tbody += v.StateName;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblCreateTime' >";
                    tbody += v.CreateTime;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblPayTime' >";
                    tbody += v.PayTime == "0001/1/1 0:00:00" ? "" : v.PayTime
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblTaskName' >";
                    tbody += v.TaskName
                    tbody += "</label></td>";
                    tbody += "</tr>"
                })
                $("#tb1").empty().append(tbody);
                $("#pager").pager({ pagenumber: pageclickednumber, pagecount: Math.ceil(pageCount / pageSize), buttonClickCallback: PageClickFunc });
            }
        },
        complete: function () {
        },
        error: function () {
        }
    });
}
//function AddMouldIMSI(sortIMSI) {
//    var data = sortIMSI == null ? {} :
//              { action: "Select", IMSI: sortIMSI, txtID:$("#seleByType").val() };
//    $.ajax({
//        type: "post",
//        data: data,
//        dataType: "json",
//        url: "../../Ajax/PayOrderManage.ashx",
//        beforeSend: function () {
//        },
//        success: function (data) {
//            if (data != null) {
//                var json = data.json;
//                var tbody = "";
//                $.each(json, function (k, v) {
//                    tbody += "<tr>"
//                    tbody += "<td><lable name='lblOrderID' id='" + v.ID + "'>";
//                    tbody += v.Name;
//                    tbody += "</label></td>";
//                    tbody += "<td><lable name='lblOrderID'>";
//                    tbody += v.OrderID;
//                    tbody += "</label></td>";
//                    tbody += "<td><lable name='lblIMSI'>";
//                    tbody += v.IMSI;
//                    tbody += "</label></td>";
//                    tbody += "<td><lable name='lblScore'>";
//                    tbody += v.Price;
//                    tbody += "</label></td>";
//                    tbody += "<td><lable name='lblState'>";
//                    tbody += v.State;
//                    tbody += "</label></td>";
//                    tbody += "<td><lable name='lblCreateTime' >";
//                    tbody += v.CreateTime;
//                    tbody += "</label></td>";
//                    tbody += "<td><lable name='lblPayTime' >";
//                    tbody += v.PayTime;
//                    tbody += "</label></td>";
//                    tbody += "</tr>"
//                })
//                $("#tb1").empty().append(tbody);
//            }
//        },
//        complete: function () {
//        },
//        error: function () {
//        }
//    })
//}